package cn.wolfcode.advice;

import cn.wolfcode.domain.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(SQLIntegrityConstraintViolationException.class)
    public Result ex(SQLIntegrityConstraintViolationException e) {
         return  Result.error("填入的数据异常");
    }
    @ExceptionHandler(DeptNameUniqueException.class)
    public Result ex(DeptNameUniqueException e) {
        return  Result.error(e.getMessage());
    }
    @ExceptionHandler(NoLoginException.class)
    public Result ex(NoLoginException e) {
        return  Result.error(e.getMessage());
    }
}
